<!DOCTYPE html>
<html lang="en">
  <head>
      <meta charset="UTF-8">
      <title>div居中</title>
      <style type="text/css">
        /*
            margin-left margin-right 如果设置为auto, 表示左右居中
         */
        div {
          border: 1px solid black;
          width: 300px;
          font-size: 40px;
          font-weight: bold;
          font-family: 华文新魏;
          margin-left: auto;
          margin-right: auto;
        }
      </style>
  </head>

  <body>
    <div>hello world~</div>
  </body>
</html>